﻿using Sidvall.Web.Security;
using Sidvall.WorkItemManager.Web.Host.Models;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Sidvall.WorkItemManager.Web.Host.Controllers
{
	public class WorkItemController : Controller
	{
		#region Public Members

		#region Item

		[AuthenticationMethodAuthorizeAttribute]
		[HttpGet]
		[Route("WorkItem/Edit/{id}", Name = "EditWorkItem")]
		public async Task<ActionResult> Item(long id)
		{
			WorkItemModel model;

			model = new WorkItemModel();
			await model.LoadAsync(id);

			return View(model);
		}

		#endregion
		#region Items

		[AuthenticationMethodAuthorizeAttribute]
		[HttpGet]
		[Route("WorkItem/List", Name = "ListWorkItems")]
		public async Task<ActionResult> Items()
		{
			WorkItemsModel model;

			model = new WorkItemsModel();
			await model.LoadAsync();

			return View(model);
		}

		#endregion

		#endregion
	}
}